﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
    xmlns:local="clr-namespace:TransformInteraction;assembly=TransformInteraction"  
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    >

    <Style TargetType="local:TransformInteractionControl">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:TransformInteractionControl">
                    <Grid RenderTransformOrigin="0.5,0.5">
                        <Grid.RenderTransform>
                            <TransformGroup>
                                <ScaleTransform x:Name="PART_Scale"/>
                                <RotateTransform x:Name="PART_Rotation" />
                                <TranslateTransform x:Name="PART_Translation" />
                            </TransformGroup>
                        </Grid.RenderTransform>

                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="CommonStates">
                                <vsm:VisualStateGroup.Transitions>
                                    <vsm:VisualTransition GeneratedDuration="0:0:0.2" To="MouseOver"/>
                                    <vsm:VisualTransition GeneratedDuration="00:00:00.2000000"/>
                                </vsm:VisualStateGroup.Transitions>
                                <vsm:VisualState x:Name="Normal">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="controlContainer" Storyboard.TargetProperty="(UIElement.Opacity)">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00.2000000" Value="0"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                                <vsm:VisualState x:Name="MouseOver">
                                    <Storyboard>
                                        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="controlContainer" Storyboard.TargetProperty="(UIElement.Opacity)" Duration="00:00:00.0010000">
                                            <SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/>
                                        </DoubleAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>

                        <ContentPresenter Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="3" Grid.RowSpan="3"/>

                        <Grid x:Name="controlContainer" Opacity="0">

                            <Grid x:Name="PART_TranslateControls" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="-5,-5,-5,-5">
                                <Rectangle Fill="Transparent" Cursor="Hand" />
                            </Grid>
                            <Grid x:Name="PART_ClickControls" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="-10,-10,0,0">
                                <Rectangle Fill="Red" Stroke="Black" Cursor="Arrow" RadiusX="3" RadiusY="3"/>
                            </Grid>
                            <Grid x:Name="PART_RotateControls"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Rectangle Fill="DimGray" Stroke="Black" RadiusX="3" RadiusY="3" Cursor="Hand" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0,-10,-10,0"/>
                                <Rectangle Fill="DimGray" Stroke="Black" RadiusX="3" RadiusY="3" Cursor="Hand" Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Margin="0,0,-10,-10"/>
                                <Rectangle Fill="DimGray" Stroke="Black" RadiusX="3" RadiusY="3" Cursor="Hand" Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Left" Margin="-10,0,0,-10"/>
                            </Grid>
                            <Grid x:Name="PART_ScaleControls"  HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                <Rectangle Fill="LightGray" Stroke="DimGray" RadiusX="3" RadiusY="3" Cursor="SizeWE" Width="20" Height="20" VerticalAlignment="Top" HorizontalAlignment="Right"/>
                                <Rectangle Fill="LightGray" Stroke="DimGray" RadiusX="3" RadiusY="3" Cursor="SizeWE" Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right"/>
                                <Rectangle Fill="LightGray" Stroke="DimGray" RadiusX="3" RadiusY="3" Cursor="SizeWE" Width="20" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Left"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>